<template>
	<view class="pages">
	<view class="container">
		<com-head textTit="我的分享" :typeVal="1" :scrollTop="scrollTop"></com-head>
		
		<template  v-if="list.length">
			<view class="shareList" v-for="(ele,index) in list" :key="index">
				<view class="time">{{ele.create_time || '2021-10-08'}}</view>
				<view class="contents" v-if="ele.goods != null">
					<view class="shopInfo">
						<image :src="ele.goods.picture[0]" mode=""></image>
						<view class="right">
							<view class="shoName">{{ele.goods.title || '-'}}</view>
							<view class="bottom">
								<view class="price">
									¥{{userInfo.vip_id >=1 ? ele.goods.sku[0].vip_price : ele.goods.sku[0].sale_price}}
								</view>
							</view>
						</view>
					</view>
					<view class="numberWrap">
						<view class="list">
							<view class="num">{{ele.click || 0}}</view>
							<view class="tit">点击数</view>
						</view>
						<view class="list">
							<view class="num">{{ele.ordersCount || 0}}</view>
							<view class="tit">有效订单数</view>
						</view>
						<view class="list">
							<view class="num">{{ele.ordersPayable || 0}}</view>
							<view class="tit">有效订单金额</view>
						</view>
					</view>
				</view>
				<view class="contents" v-else>
					<view class="shopInfo">
						<image :src="ele.project.pic" mode=""></image>
						<view class="right">
							<view class="shoName">{{ele.project.name || '-'}}</view>
							<view class="bottom">
								<view class="effectList">
									<view class="effect" v-for="(list,index) in ele.project.tags">{{list}}</view>
									<!-- <view class="effect" v-for="(list,index) in 2">打撒肥嘟</view> -->
								</view>
							</view>
							<view class="bottom">
								<view class="price">
									¥{{(userInfo.vip_id >=1 ? ele.project.vip_price : ele.project.price || 0)}}
								</view>
							</view>
						</view>
					</view>
					<view class="numberWrap">
						<view class="list">
							<view class="num">{{ele.click || 0}}</view>
							<view class="tit">点击数</view>
						</view>
						<view class="list">
							<view class="num">{{ele.ordersCount || 0}}</view>
							<view class="tit">有效订单数</view>
						</view>
						<view class="list">
							<view class="num">{{ele.ordersPayable || 0}}</view>
							<view class="tit">有效订单金额</view>
						</view>
					</view>
				</view>
			</view>
			<u-loadmore margin-top="60" margin-bottom="50" :status="status" />
		</template>
		<view class="noDate" v-else>
			<image src="https://willmid-img.oss-cn-shanghai.aliyuncs.com/2021/09/10/2x-8.png" mode=""></image>
			<view>暂无更多分享记录~</view>
		</view>
	</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				list:[],
				status:'loading',
				total:0,
				page:1,
				scrollTop: 0
			}
		},
		onPageScroll(e){
			this.scrollTop = e.scrollTop
		},
		onReachBottom() {
			if (this.total > this.list.length) {
				this.page++;
				this.getUserShare();
			}
		},
		async onShow() {
			this.list =[]
			this.getUserShare()
		},
		methods: {
			async getUserShare(){
				let {code,data} = await this.$u.api.getUserShare({page:this.page});
				if(this.page == 1 && !data.data.lenght){
					this.status = 'nomore';
				}
				data.data.forEach(ele=>{
					if(ele.goods != null){
						ele.goods.picture = ele.goods.picture.split(",")
					}else{
						ele.project.tags = ele.project.tags.split(",")
					}
				})
				this.list = [...this.list, ...data.data];
				this.total = data.total;
				if (this.total <= this.list.length) this.status = 'nomore';
				else this.status = 'loading';
			},
		}
	}
</script>

<style lang="scss" scoped >
.pages{
	width: 100%;
	height: 100%;
	background-image: url('https://jiudao123.oss-cn-shanghai.aliyuncs.com/store/img/bg.png') !important;
	background-repeat: no-repeat;
	background-size: cover;
}
	
	
.container{
	padding: 50rpx 32rpx;
	.noDate{
		width: 360rpx;
		position: absolute;
		left: 50%;
		top: 34%;
		transform: translate(-50%,-50%);
		color: #666666;
		font-size: 26rpx;
		text-align: center;
		image{
			width: 360rpx;
			height: 310rpx;
			display: block;
			margin-bottom: 78rpx;
		}
	}
	.shareList{
		.time{
			margin: 32rpx 0 24rpx 0;
			color: #4D5562;
			font-size: 26rpx;
		}
		.contents{
			padding: 32rpx 32rpx 52rpx 32rpx;
			background-color: #FFFFFF;
			border-radius: 15rpx;
			.shopInfo{
				display: flex;
				align-self: center;
				padding-bottom: 32rpx;
				border-bottom: 1rpx solid rgba(142,142,142,.14);
				image{
					flex: none;
					width: 157rpx;
					height: 158rpx;
					margin-right: 28rpx;
					border-radius: 14rpx;
				}
				.right{
					position: relative;
					.shoName{
						font-size: 32rpx;
						color: #000000;
						line-height: 45rpx;
						margin-bottom: 15rpx;
					}
					.bottom{
						width: 450rpx;
						display: flex;
						justify-content: space-between;
						align-items: center;
						.effectList{
							display: flex;
							.effect{
								padding: 10rpx 20rpx;
								background: #E6F2F1;
								border-radius: 68rpx;
								color: #007664;
								font-size: 24rpx;
								margin-right: 20rpx;
							}
							.effect:last-child{
								margin-right: 0;
							}
						}
						
					}
					.price{
						color: #007664;
						font-size: 30rpx;
						position: absolute;
						bottom: 0;
					}
				}
			}
			.numberWrap{
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding-top: 32rpx;
				.list{
					text-align: center;
					.num{
						font-size: 32rpx;
						color: #007664;
						line-height: 45rpx;
						letter-spacing: 1rpx;
						margin-bottom: 16rpx;
					}
					.tit{
						color: #666666;
						font-size: 26rpx;
					}
				}
			}
		}
	}
}
</style>
<style >
page{
	background-color: #F6F7FA;
}
</style>
